package designprinciples.opencloseprinciple;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @program: MyTank
 * @description:
 * @author: 王术平
 * @create: 2021-01-23 19:15
 **/
public class Client {
    public static void main(String[] args) {
        Person p = new Person("小明");
        p.feed(new Dog());
    }
}

class Dog {
    public void eat(Person p) {
        System.out.println(p.getName()+"正在喂狗吃屎");
    }
}

@AllArgsConstructor
@Data
class Person {
    private String name;
    public void feed(Dog dog) {
        dog.eat(this);
    }
}